<?php
namespace Home\Controller;
use Think\Controller;
class SearchController extends BaseController {
    
	public function index(){
		$search=$_GET["search"];
		$p=$_GET["P"]?$_GET["P"]:1;
		$pre=10;
		
		if($search){
			
	       		$where["article_content"]=array("like","%$search%");
	       		$where["article_name"]=array("like","%$search%");
	       		$where["article_remark"]=array("like","%$search%");
				$where['_logic'] = 'or';
				$condition['_complex'] = $where;
	       	
	      
	       		$condition["article_status"]=array("eq",2);
	       
	
		
		//查到所有产品库的子ID
		$article =M('article');
		$article_list=$article->where($condition)->order('article_id desc')->limit($pre,$p-1)->select();
		$this->assign('article_list', $article_list);
		
		$count=$article->where($condition)->count();
	    $pcount=ceil($count/$pre);
		
		$this->assign('pcount', $pcount);
		$this->assign('p', $p);
		$this->assign('id', $id);
		
		$this->assign("search",$search);
		
		}
        $this->display("search");
    }
    
    
  
}